<header class="layout head padding-small">
    <a href="javascript:back(true);" class="hBack float-left"></a>
    <h4 class="hTxt float-left text-center text-white">找回密码（第二步）</h4>
    <a href="javascript:;" id="btnJdkey" class="hHlep float-right"></a>
</header>
<div class="margin bg-white padding radius-big">
    <!--找回密码的步骤S-->
    <div class="revise-mobile">
        <div class="step text-small">
            <!--正在那一步的添加类active  已经通过了的添加类complete-->
            <div class="step-bar complete " style="width:25%;"><span class="step-point icon-check"></span><span class="step-text">账号验证</span></span></div>
            <div class="step-bar active" style="width:25%;"><span class="step-point">2</span><span class="step-text">身份校验</span></div>
            <div class="step-bar" style="width:25%;"><span class="step-point">3</span><span class="step-text">新密码</span></div>
            <div class="step-bar" style="width:25%;"><span class="step-point">4</span><span class="step-text">成功</span></div>
        </div>
    </div>


    <!--步骤2S-->
    <div class="mod-second">
        <div>昵称：<span><?php echo $output['member']['member_name'];?></span></div>
        <div>请选择校验方式</div>
        <?php $valid_list = $output['valid_list'];?>
        <?php if(!empty($valid_list) && is_array($valid_list)){?>
        <div class="clearfix">
            <?php if(isset($valid_list['mobile'])){?>
            <a href="javascript:;" class="x49 padding text-center border border-blue radius-big sendMobileCode" data-type="mobile">
                <div id="mobile_div">
                <i class="icon-comment text-blue "></i>
                <span class="mobile"><?php echo memberModel::hidePartMobileOrEmail($valid_list['mobile']);?></span>
                <div>短信验证</div>
                </div>
                <div id="send_code_tip" style="display: none;">
                <!--发送后-->
                <i class="icon-comment text-blue "></i>
                <span id="mobile_text" class="mobile text-blue">60秒后</span>
                <div class="text-blue">重新发送</div>
                </div>
            </a>
            <?php }?>
            <?php if(isset($valid_list['email'])){?>
            <a href="javascript:;" class="x49 padding text-center border border-green radius-big sendMobileCode" data-type="email">
                <i class="icon-envelope-square text-green "></i>
                <span class="mailBox"><?php echo memberModel::hidePartMobileOrEmail($valid_list['email']);?></span>
                <div>邮箱验证</div>
            </a>
            <?php }?>
        </div>
        <?php }?>
        <div class="field">
            <form id="check_code" method="post" action="index.php?act=login&op=find_password_step3">
                <input type="text" name="code" id="code" placeholder="请输入验证码" class="border border-ef7f7e layout padding radius-big">
            </form>
        </div>
        <div><input type="button" id="submitCode" value="下一步" class="border-none bg-red text-white layout padding radius-big "></div>
    </div>
    <!--步骤2E-->

</div>

<script>
$(function(){
    //获取验证码
	$(".sendMobileCode").click(function(event){
		event.preventDefault();
	    var getLink = $(this),valid_mode=$(this).attr('data-type');
	    var $send_code_tip = $("#send_code_tip #mobile_text");

	    if(getLink.attr("data-status") == "load"){
	        alert("请稍后再试");
	        return false;
		    }

	    var send_data = {};
	    send_data.valid_mode = valid_mode;
	    send_data.member_id = <?php echo $output['member']['member_id'];?>;
	    $.post("index.php?act=login&op=ajax_send_mobile_code", send_data, function(data){
	    	   if(!data.rs){
		    	   alert(data.msg);
		    	   }
	    	   else{
                   if(valid_mode=='mobile'){
                       var tmpHtml = '';
                       var time = 60;
                       var countTime = setInterval(function(){
                           $('#send_code_tip').show();
                           $('#mobile_div').hide();
                           time--;
                           if(time == 0){
                               getLink.attr("data-status", "");
                               $('#mobile_div').show();
                               $('#send_code_tip').hide();
                               clearInterval(countTime);
                               return false;
                           }
                           tmpHtml = "<b>" + time + " </b>秒后";
                           $('#mobile_text').html(tmpHtml);
                           getLink.attr("data-status", "load");
                       }, 1000);
                   }
		    	   }	   
	    	   },"json");
    });

    //提交验证码
    $("#submitCode").click(function(event){
        event.preventDefault();
        
        var code = $("input[name='code']");

        if(code.val().length < 1){
            alert("请填写校验码");
            code.focus();
            return false;
        }

        $.post("index.php?act=login&op=check_find_password_code", {code:code.val()}, function(data){
	    	   if(!data.rs){
		    	   alert(data.msg);
		    	   return false;
		       }else{
		    	   $("#check_code").submit();
			   }
            }, "json");
        });    
});
</script>